package com.blocks;

import java.util.LinkedList;
import java.util.List;

import com.blocks.blocks.Block;
import com.blocks.blocks.PowerBlock;

public class Clusters {

	private List<Block> blockList;
	private List<PowerBlock> powerList;
	
	private boolean changed = false;
	
	public List<Block> getBlockList() {
		return blockList;
	}

	public void setBlockList(List<Block> blockList) {
		this.blockList = blockList;
	}

	public List<PowerBlock> getPowerList() {
		return powerList;
	}

	public void setPowerList(List<PowerBlock> powerList) {
		this.powerList = powerList;
	}
	
	public void init()
	{
		blockList = new LinkedList<Block>();
		powerList = new LinkedList<PowerBlock>();
		setChanged(false);
		
	}
	
	public boolean addBlock(Block blk)
	{
		if(blockList.add(blk) == true)
		{
			blk.setClust(this);
			setChanged(true);
			if(PowerBlock.class.isAssignableFrom(blk.getClass()))
			{
				powerList.add((PowerBlock)blk);
				return true;
			}
			return true;
		}
		return false;
	}

	public void setChanged(boolean changed) {
		this.changed = changed;
	}

	public boolean isChanged() {
		return changed;
	}
}
